import {ViewType, createStructArrayType} from "../util/StructArray";

/**
 * An index array stores Uint16 indicies of vertexes in a corresponding vertex array. We use
 * two kinds of index arrays: arrays storing groups of three indicies, forming triangles; and
 * arrays storing pairs of indicies, forming line segments.
 * @private
 */

function createIndexArrayType(components: number) {
  return createStructArrayType({
    members: [{
      type: ViewType.Uint16, // 顶点索引， 数据类型gl.UNSIGNED_SHORT
      name: "vertices",
      components
    }]
  });
}

export const LineIndexArray = createIndexArrayType(2);
export const TriangleIndexArray = createIndexArrayType(3);
